/*
 * Describe the Chess Board of AK(DSQ)
 *
 * Provide the operations like 'CreatePossibleMove','IsValidMove','IsGameOver' and 'Evaluate' for DSQPlayer
 * Set CDSQTTHHEngine as the friend class for the flexible access
 *
 */

#ifndef _DSQBOARD_H
#define _DSQBOARD_H

#include "CDSQBaseInfo.h"

class CDSQTTHHEngine;

class CDSQBoard
{
public:
	CDSQBoard(){};
	virtual ~CDSQBoard(){};

	virtual void backToInitialState();

	void CreatePossibleMove(int, int);
	void Gen_LionMove(int, int, int);
	void Gen_TigerMove(int, int, int);
	void Gen_Move(int, int, int);
	void AddMove(int nFromX, int nFromY, int nToX, int nToY, int depth);
	/*Is valid move.*/
	int IsValidMove(int nFromX, int nFromY, int nToX, int nToY);
	/*Judge the relative pieces.*/
	int IsRelativePiece(int nFromX, int nFromY, int nToX, int nToY);

	unsigned int MakeMove(PieceMove* move);
	void UnMakeMove(PieceMove* move,PieceIndex type);
	int IsGameOver(int nDepth, AKSideIndex side);
	
	int Evaluate(int bIsRightTurn);
	void GetRelatePiece(int, int);
	void AddPoint(int, int);
	void InitChessEvaluations();

protected:
	friend class CDSQTTHHEngine;

private:
	PieceIndex m_CurPosition[Row][Col];
	int m_PossibleMovementCounter;
	PieceMove m_MoveList[MaxSearchDepth][MaxPossibleMovement];

	int m_RelatePosCounter;
	
	//For Evaluation
	CellPoint RelatePos[4];
	int m_BaseValue[18];
	int m_chessValue[Row][Col];
	int m_AttackPos[Row][Col];
	int m_GuardPos[Row][Col];
};

#endif	//_DSQBOARD_H